FROM node:lts AS deps
ARG NODE_ENV
ARG NEXT_PUBLIC_API_BASE_URL
ARG GITHUB_CLIENT_ID
ENV NODE_ENV $NODE_ENV
ENV NEXT_PUBLIC_GITHUB_CLIENT_ID $GITHUB_CLIENT_ID
ENV NEXT_PUBLIC_API_BASE_URL $NEXT_PUBLIC_API_BASE_URL
WORKDIR /app

COPY package*.json ./
RUN npm ci

FROM node:lts AS builder
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules

CMD ["npm", "run", "dev"]